var e = require;
var t = module;
var n = exports;
var o,
    i =
        (this && this.__extends) ||
        ((o = function (e, t) {
            return (o =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
                })(e, t);
        }),
        function (e, t) {
            function n() {
                this.constructor = e;
            }
            o(e, t), (e.prototype = null === t ? Object.create(t) : ((n.prototype = t.prototype), new n()));
        }),
    r =
        (this && this.__decorate) ||
        function (e, t, n, o) {
            var i,
                r = arguments.length,
                a = r < 3 ? t : null === o ? (o = Object.getOwnPropertyDescriptor(t, n)) : o;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) a = Reflect.decorate(e, t, n, o);
            else
                for (var s = e.length - 1; 0 <= s; s--)
                    (i = e[s]) && (a = (r < 3 ? i(a) : 3 < r ? i(t, n, a) : i(t, n)) || a);
            return 3 < r && a && Object.defineProperty(t, n, a), a;
        };
Object.defineProperty(n, "__esModule", {value: !0});
var a,
    s = e("index"),
    c = e("env"),
    l = e("events"),
    u = e("platform-const"),
    p = e("user-data"),
    h = e("base-panel"),
    d = e("switch-button"),
    f = e("panel-manager"),
    m = e("player-info"),
    y = e("player-war"),
    g = e("game"),
    t = cc._decorator,
    e = t.ccclass,
    t = t.property,
    e =
        ((a = h.default),
        i(v, a),
        (v.prototype.init = function () {}),
        (v.prototype.start = function () {
            this.gmNode && (this.gmNode.active = c.env.mode == c.EnvMode.TEST);
            var e = p.userData.getSetting();
            (this.m_bAudioOn = e.effectSound),
                (this.m_bMusicOn = e.bgmSound),
                (this.m_bVibrateOn = e.vibrate),
                this.updateAudioBtn(),
                this.updateMusicBtn(),
                this.updateVibrateBtn(),
                (this.varsionLabel &&(this.varsionLabel.string = "v" + c.env.version)),
                (this.varsionLabel &&(this.idLabel.string = "ID:" + p.userData.getUid())),
                s.showNode(this.qqGroup, !1),
                (s.platform.string() !== u.PlatformCode.QQ && s.platform.string() !== u.PlatformCode.Vivo) ||
                    s.showNode(this.qqGroup, !0);
        }),
        (v.prototype.onAudioBtnTap = function () {
            (this.m_bAudioOn = !this.m_bAudioOn),
                this.updateAudioBtn(),
                p.userData.setSetting({effectSound: this.m_bAudioOn}),
                s.platform.trackEvent("switch", {item: "audio", bool: this.m_bAudioOn});
        }),
        (v.prototype.updateAudioBtn = function () {
            null != this.audioBtn && this.audioBtn.setState(this.m_bAudioOn);
        }),
        (v.prototype.onMusicBtnTap = function () {
            (this.m_bMusicOn = !this.m_bMusicOn),
                this.updateMusicBtn(),
                p.userData.setSetting({bgmSound: this.m_bMusicOn}),
                s.platform.trackEvent("switch", {item: "music", bool: this.m_bMusicOn});
        }),
        (v.prototype.updateMusicBtn = function () {
            null != this.musicBtn && this.musicBtn.setState(this.m_bMusicOn);
        }),
        (v.prototype.onVibrateBtnTap = function () {
            (this.m_bVibrateOn = !this.m_bVibrateOn),
                this.updateVibrateBtn(),
                p.userData.setSetting({vibrate: this.m_bVibrateOn}),
                s.platform.trackEvent("switch", {item: "vibrate", bool: this.m_bVibrateOn});
        }),
        (v.prototype.updateVibrateBtn = function () {
            null != this.vibrateBtn && this.vibrateBtn.setState(this.m_bVibrateOn);
        }),
        (v.prototype.onAgreementBtnTap = function () {
            f.PanelManager.ins.open("prefab/panel/informationPanel", {type: 1});
        }),
        (v.prototype.onPrivacyBtnTap = function () {
            f.PanelManager.ins.open("prefab/panel/informationPanel", {type: 2});
        }),
        (v.prototype.hideThis = function () {
            l.operEvent.emit({action: l.default.startWarTime, data: {}}), this.hide();
        }),
        (v.prototype.clearLayer = function () {
            this.hide(), m.playerInfo.resetData();
        }),
        (v.prototype.restart = function () {
            var e, t;
            this.hide(),
                m.playerInfo.getGameType() === m.gameType.nomal
                    ? m.playerInfo.restartData()
                    : m.playerInfo.getGameType() === m.gameType.war &&
                      (0 === (e = y.playerWar.getWarLevel()) && y.playerWar.setIsGuideLevel(!0),
                      (t = g.default.ins.getWarTimes()),
                      s.platform.trackEvent("end_challenge", {
                          step: "reset",
                          level_time: t,
                          level: e + 1,
                          useADArea: y.playerWar.getUseADAreaCount()
                      }),
                      (t = y.playerWar.getWarLevelCount(e)),
                      y.playerWar.setWarLevelCount(e, t + 1),
                      s.platform.trackEvent("start_challenge", {level: e + 1, number: t + 1})),
                l.operEvent.emit({action: l.default.restartCellLayer, data: {cellDelayTime: 0}});
            this.node.active = !1;
        }),
        (v.prototype.toLoading = function () {
            var e, t;
            p.userData.saveLocalData(),
                m.playerInfo.getGameType() === m.gameType.war &&
                    ((e = y.playerWar.getWarLevel()),
                    (t = g.default.ins.getWarTimes()),
                    s.platform.trackEvent("end_challenge", {
                        step: "quit",
                        level_time: t,
                        level: e + 1,
                        useADArea: y.playerWar.getUseADAreaCount()
                    })),
                cc.director.loadScene("main", function () {
                    l.operEvent.clear();
                });
        }),
        (v.prototype.unlock = function () {
            this.hide(),
                y.playerWar.setWarLevelUnlock(0, !0),
                y.playerWar.setWarLevelUnlock(1, !0),
                y.playerWar.setWarLevelUnlock(2, !0),
                y.playerWar.setWarLevelUnlock(3, !0),
                y.playerWar.setWarLevelUnlock(4, !0);
        }),
        (v.prototype.promp = function () {
            this.hide(), m.playerInfo.setShowPromp(!0);
        }),
        (v.prototype.level = function () {
            m.playerInfo.setLevel(9), m.playerInfo.restartData(), this.hide();
        }),
        r([t(d.default)], v.prototype, "audioBtn", void 0),
        r([t(d.default)], v.prototype, "musicBtn", void 0),
        r([t(d.default)], v.prototype, "vibrateBtn", void 0),
        r([t(cc.Node)], v.prototype, "qqGroup", void 0),
        r([t(cc.Label)], v.prototype, "varsionLabel", void 0),
        r([t(cc.Label)], v.prototype, "idLabel", void 0),
        r([t(cc.Node)], v.prototype, "gmNode", void 0),
        r([e], v));
function v() {
    var e = (null !== a && a.apply(this, arguments)) || this;
    return (
        (e.audioBtn = null),
        (e.musicBtn = null),
        (e.vibrateBtn = null),
        (e.qqGroup = null),
        (e.varsionLabel = null),
        (e.idLabel = null),
        (e.gmNode = null),
        (e.m_bAudioOn = !0),
        (e.m_bMusicOn = !0),
        (e.m_bVibrateOn = !0),
        (e.isPromp = !1),
        e
    );
}
n.default = e;
